#!/usr/bin/env python

import commands
from urllib import urlencode,quote




def main():
    statCmdStr = """iostat|head -n4|tail -n1|awk '{print $1}';netstat -s|grep 'Tcp:' -A 10|head -n6|tail -n1|awk '{print $1}';vmstat|head -n3|tail -n1|awk '{print $4}'"""

    status,output = commands.getstatusoutput(statCmdStr)

    print output


def cpuUsage():
    cmd = """iostat|head -n4|tail -n1|awk '{print $1}'"""
    status,output = commands.getstatusoutput(cmd)
    return output

def free():
    cmd = """vmstat|head -n3|tail -n1|awk '{print $4}'"""
    status,output = commands.getstatusoutput(cmd)
    return output


def ipStatus():
    '''return data format
    0- total packets received
    1- with invalid addresses
    2- forwarded
    3- incoming packets discarded
    4- incoming packets delivered
    5- requests sent out
    '''

    cmd = """netstat -s|grep "Ip:" -A6|tail -n6|awk '{print $1}'"""
    status,output = commands.getstatusoutput(cmd)
    ret = output.split("\n")
    return ret




if __name__ == '__main__':
    ret = ipStatus()
    print ret[0]

    

